home *** CD-ROM | disk | FTP | other *** search
/ PC-X 1997 October / pcx14_9710.iso / swag / delphi.swg / 0217_Find the Network Username.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-03-04  |  451 b   |  26 lines

  1.  
  2. Windows API function:
  3.  
  4. BOOL GetUserName(
  5.  
  6.     LPTSTR  lpBuffer,    // address of name buffer 
  7.     LPDWORD  nSize     // address of size of name buffer 
  8.    );
  9.  
  10. Delphi example:
  11.  
  12. procedure X;
  13. var
  14.   USize : DWORD;
  15.   pUName : pchar;
  16.   sUName:string;
  17. begin
  18.   USize := 30;
  19.   getmem(pUName, USize);
  20.   if GetUserName(pUName, USize) then
  21.      sUserName := StrPas(pUName)
  22.   else
  23.      sUserName := 'Unknown';
  24.   freemem( pUName, USize );
  25. end;
  26.